// import com.alibaba.druid.sql.ast.SQLExpr_ptr;
// import com.alibaba.druid.sql.ast.SQLName;
// import com.alibaba.druid.sql.ast.statement.SQLCreateStatement;
// import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
// import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "MySqlCreateUserStatement.h"
#include "../../../../ast/SQLExpr.h"
#include "../../../../ast/SQLName.h"
#include "../../../../ast/statement/SQLCreateStatement.h"
#include "../../visitor/MySqlASTVisitor.h"
#include "../../../../../utils/listTran.h"

SQLExpr_ptr MySqlCreateUserStatement_UserSpecification::getUser()
{
  return user;
}

void MySqlCreateUserStatement_UserSpecification::setUser(SQLExpr_ptr user)
{
  this->user = std::dynamic_pointer_cast<SQLName>(user);
}

BOOL_ptr MySqlCreateUserStatement_UserSpecification::isPasswordHash()
{
  return passwordHash;
}

void MySqlCreateUserStatement_UserSpecification::setPasswordHash(BOOL_ptr passwordHash)
{
  this->passwordHash = passwordHash;
}

SQLExpr_ptr MySqlCreateUserStatement_UserSpecification::getPassword()
{
  return password;
}

void MySqlCreateUserStatement_UserSpecification::setPassword(SQLExpr_ptr password)
{
  this->password = password;
}

SQLExpr_ptr MySqlCreateUserStatement_UserSpecification::getAuthPlugin()
{
  return authPlugin;
}

void MySqlCreateUserStatement_UserSpecification::setAuthPlugin(SQLExpr_ptr authPlugin)
{
  this->authPlugin = authPlugin;
}

BOOL_ptr MySqlCreateUserStatement_UserSpecification::isPluginAs()
{
  return pluginAs;
}

void MySqlCreateUserStatement_UserSpecification::setPluginAs(BOOL_ptr pluginAs)
{
  this->pluginAs = pluginAs;
}

// @Override
void MySqlCreateUserStatement_UserSpecification::accept0(MySqlASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(MySqlCreateUserStatement_UserSpecification)))
  {
    acceptChild(visitor, user);
    acceptChild(visitor, password);
    acceptChild(visitor, authPlugin);
  }
  visitor->endVisit(SharedObject(MySqlCreateUserStatement_UserSpecification));
}

MySqlCreateUserStatement::MySqlCreateUserStatement()
{
  users = std::make_shared<std::list<MySqlCreateUserStatement_UserSpecification_ptr>>();
}
MySqlCreateUserStatement_UserSpecification_list_ptr MySqlCreateUserStatement::getUsers()
{
  return users;
}

BOOL_ptr MySqlCreateUserStatement::isIfNotExists()
{
  return ifNotExists;
}

void MySqlCreateUserStatement::setIfNotExists(BOOL_ptr ifNotExists)
{
  this->ifNotExists = ifNotExists;
}

void MySqlCreateUserStatement::addUser(MySqlCreateUserStatement_UserSpecification_ptr user)
{
  if (user != nullptr)
  {
    user->setParent(SharedObject(MySqlCreateUserStatement));
  }
  this->users->push_back(user);
}

// @Override
void MySqlCreateUserStatement::accept0(MySqlASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(MySqlCreateUserStatement)))
  {
    SQLObject_list_ptr tmp = ListTran::tran_class<MySqlCreateUserStatement_UserSpecification, SQLObject>(users);
    acceptChild(visitor, tmp);
  }
  visitor->endVisit(SharedObject(MySqlCreateUserStatement));
}
